<{extends file="layout.tpl"}>

<{block name=css}>
<style type="text/css">
.m-addUser-box{ width: 460px;	margin: 30px auto;}
.m-addUser-box div{ margin: 15px 0; }
.m-addUser-box label{ display: inline-block; width: 100px; text-align: right; }
.m-addUser-box input{ display: inline-block; width:  340px;  }
.m-addUser-box div:last-child{ text-align: center; margin-top: 30px; }
</style>
<{/block}>


<{block name=content}>
<section class="m-panel-box">
	<h4>添加用户信息</h4>
	<div class="m-panel-body">
		<div class="m-addUser-box">
			<form class="m-addUser-form">
				<div>
					<label>用户名：</label>
					<input type="text" name="username" class="form-control m-addUser-username" placeholder="用户名">
				</div>
				<div>
					<label>真实姓名：</label>
					<input type="text" name="realname" class="form-control m-addUser-relName" placeholder="真实姓名">
				</div>
				<div>
					<label>联系邮箱：</label>
					<input type="text" name="email" class="form-control m-addUser-email" placeholder="联系邮箱：例如XXX@XX.com">
				</div>
				<div>
					<label>密码：</label>
					<input type="password" name="password" class="form-control m-addUser-pwd" placeholder="请输入密码">
				</div>
				<div>
					<label>确认密码：</label>
					<input type="password" name="password" class="form-control m-addUser-repwd" placeholder="请确认密码">
				</div>
				<div>
					<span class="btn btn-md btn-primary m-addUser-btn">确认提交</span>
				</div>
			</form>
		</div>
	</div>
</section>
<{/block}>

<{block name=js}>
<script type="text/javascript">
	$('.m-addUser-btn').click(function(){
		if($('.m-addUser-username').val() == '' || $('.m-addUser-pwd').val() == '' || $('.m-addUser-email').val() == ''
			|| $('.m-addUser-relName').val() == '' || $('.m-addUser-repwd') == ''){
			layer.msg('上述选项都为必填项！');
			return;
		}
		var reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		if($('.m-addUser-email').val().match(reg) == null){
			layer.msg("联系方式格式错误，请重新输入！");
			return;
		}

		if($('.m-addUser-pwd').val() != $('.m-addUser-repwd').val()){
			layer.msg("两次密码不一致！");
			return;
		}
		ajaxObj('/UserManage/addUser', 'post', $('.m-addUser-form').serialize(), function(obj){
			if(obj.code == 1){
				$('.m-addUser-form')[0].reset();
				layer.msg('添加成功！');
			}
		})
	})
</script>
<{/block}>